﻿Imports OMANE.Common.UI
Imports System.Windows.Controls

Public Class ViewDashboard


   
    Private Sub ViewDashboard_DataContextChanged(sender As Object, e As Windows.DependencyPropertyChangedEventArgs) Handles Me.DataContextChanged
        UndoRedoEngine.Instance.ActiveContext = TryCast(Me.DataContext, ViewModelDashboard)
    End Sub

    Private Sub CollerMenuItemClick(sender As Object, e As Windows.RoutedEventArgs)
        Dim x As XElement = Nothing
        'If Not Windows.Clipboard.GetDataObject().GetDataPresent(GetType(XElement)) Then
        '    MsgBox("Aucun objet trouve")

        If Not Windows.Clipboard.ContainsText() Then
            MsgBox("Aucun texte trouve")
        Else
            Try
                x = XElement.Parse(Windows.Clipboard.GetText())
            Catch ex As Exception
                MsgBox("Impossible de coller ", MsgBoxStyle.Critical)
            End Try
        End If
        'Else
        'Try
        '    x = Windows.Clipboard.GetDataObject().GetData(GetType(XElement))
        'Catch ex As Exception
        '    MsgBox("Impossible de coller ", MsgBoxStyle.Critical)
        'End Try
        'End If
        If x Is Nothing Then Return
        Try
            TryCast(Me.DataContext, ViewModelDashboard).LoadZone(x.<Zone>.FirstOrDefault(), True)
        Catch ex As Exception
            MsgBox("Donnees Invalides ", MsgBoxStyle.Critical)
        End Try
    End Sub
End Class
